package com.bysj.yqsht.web.controller;

import com.bysj.yqsht.bean.CheckTeacher;
import com.bysj.yqsht.bean.extend.CheckTeacherExtend;
import com.bysj.yqsht.service.ICheckTeacherService;
import com.bysj.yqsht.utils.Message;
import com.bysj.yqsht.utils.MessageUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("checkTeacher")
@Api(description = "老师考勤管理接口")
public class CheckTeacherController {
    @Autowired
    private ICheckTeacherService checkTeacherService;

    @GetMapping("findAll")
    public Message findAll(){
        List<CheckTeacher> CheckTeacher = checkTeacherService.findAll();
        return MessageUtil.success(CheckTeacher);
    }
    @GetMapping("findWithAll")
    public Message findWithAll(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int limit){
        List<CheckTeacherExtend> CheckTeacherExtend = checkTeacherService.findWithAll(pageNum,limit);
        return MessageUtil.success(CheckTeacherExtend);
    }
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdare(CheckTeacher checkTeacher){
        checkTeacherService.saveOrUpdate(checkTeacher);
        return MessageUtil.success("修改或新增成功");

    }
    @GetMapping("deleteById")
    public Message deleteById(Long id){
        checkTeacherService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
    @GetMapping("findWithAllByTeacherId")
        public Message findWithAllByTeacherId (Long teacherId,Long classesId,String type){
            List<CheckTeacherExtend> checkTeacherExtends = checkTeacherService.findWithAllByTeacherId(teacherId,classesId,type);
            return MessageUtil.success(checkTeacherExtends);
        }




}
